package com.common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * @classDescription:
 * @author:xiayingjie
 * @createTime:16/8/16
 */
//@Configuration
public class RedisConfig {
    @Bean
    public RedisConnectionFactory redisCF(){
        JedisConnectionFactory jcf=new JedisConnectionFactory();
        jcf.setPort(6379);
//        jcf.setPassword("");
        //jcf.setHostName();
        jcf.setUsePool(true);
        return  jcf;
    }

    @Bean
    public RedisTemplate redisTemplate(RedisConnectionFactory redisCF){
        RedisTemplate redis=new RedisTemplate();
        redis.setConnectionFactory(redisCF);
        return redis;
    }

    @Bean
    StringRedisTemplate stringRedisTemplate(RedisConnectionFactory redisCF){
        return new StringRedisTemplate(redisCF);
    }


}
